package com.zpark.se.io.reader;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;

/**
 * @PackageName: com.zpark.se.io.reader
 * @ClassName: Demo02_01
 * @Description:
 * @author: RZS
 * @date: 2024/11/22  15:34
 */
public class Demo02_01 {
    public static void main(String[] args) throws Exception {
        // 定义文件的路径
        String path = "src/com/zpark/se/io/reader/a/demo01.txt";
        // 创建文件字符输入流对象
        FileReader fr = new FileReader(
                new File(path)
        );

        // 读取数据
        char[] data = new char[8];
        int len = 0;
        // 循环读取
        while ((len = fr.read(data)) != -1) {
            // 将读取的数据转换为字符串
            String str = new String(data, 0, len);
            System.out.print(str);
        }


        // 关闭流
        fr.close();
    }
}
